grammar: Update to support every and in keywords in Rego v1 syntax - #210
Conversation
| ref-arg-brack ::= "[" ( expr | "_" ) "]" | ||
| ref-arg-dot ::= "." var | ||
| var ::= ASCII_LETTER | "contains" | ||
| var ::= ASCII_LETTER | "contains" | "in" |
There was a problem hiding this comment.
Is this so that in v0 code we show in correctly if it's a var? Do we need to do the same for every/some?
There was a problem hiding this comment.
Yes exactly, from what I saw some was the only keyword reserved in v0, so technically the others could be used as vars. I added every and if here as well, as well as a test
| literal ::= ( every-decl | some-decl | literal-expr | "not" literal-expr ) with-modifier* | ||
| with-modifier ::= "with" term "as" term | ||
| some-decl ::= "some" var ( "," var )* | ||
| some-decl ::= "some" var ( "," var )* ( "in" expr )? |
There was a problem hiding this comment.
( "," var )* is there a reason for 0 or more here? I think we can have 1 or 2.
And then for every, we can have 1, 2 as well.
There was a problem hiding this comment.
Yeah good catch, this rule originally matched some followed by any number of vars for declaration, just added a different rule for the some x,y in foo case to properly match 1 or 2 vars
charlieegan3
left a comment
There was a problem hiding this comment.
LGTM pending some responses on the comments
|
Might be nice to make a short CL update too to it's shown in the next release. |
Signed-off-by: seanledford <s_ledford@apple.com>
Signed-off-by: seanledford <s_ledford@apple.com>
Signed-off-by: seanledford <s_ledford@apple.com>
4221b8a to
774c7db
Compare
This PR updates the Rego.bnf grammar to support modern Rego v1 syntax in rule bodies. Specifically, supporting
everyandinkeywords. The lack of support for these keywords and their related syntax was causing parser errors in Rego v1 files.Description
Before:
After: